<template>
    <el-drawer v-model="drawer" title="产品预览" :with-header="true" custom-class="drawers" size="32%">
        <div class="slot"></div>

        <div class="product_box scroll" @scroll="scroll">
            <div class="mobile_box">
                <div class="white_box">
                    <div class="title_box">
                        <el-icon><ArrowLeftBold /></el-icon>
                        <h3 class="title_r">产品详情</h3>
                    </div>
                    <div class="product_pic">
                        <el-image class="img_right" :src="productPopupData?.cover" style="width: 100%">
                            <template #error>
                                <el-image src="/static/file/pic.png" style="width: 100%"></el-image>
                            </template>
                        </el-image>
                    </div>
                    <div style="padding: 0 10px">
                        <div class="product_information">
                            <div>{{ productPopupData?.product_name }}</div>
                            <div class="Price">
                                <span>
                                    售价：
                                    <span v-if="productPopupData.min_price == productPopupData.max_price">
                                        ￥{{ productPopupData.min_price }}
                                    </span>
                                    <span v-else>
                                        ￥{{ productPopupData.min_price }}-￥{{ productPopupData.max_price }}
                                    </span>
                                </span>
                                <span>当前规格库存：{{ productPopupData.total_stock }}</span>
                            </div>
                            <div class="specs_box">
                                <div v-if="productPopupData.specifications.length !== 0" class="specs_rule">
                                    选择规格：
                                </div>
                                <div v-for="(item, index) in productPopupData.specifications" :key="item.index">
                                    <span :class="['specs_text', index == 0 ? 'active' : '']">{{ item.name }}</span>
                                </div>
                                <div v-if="productPopupData.specifications == ''" class="specs_rule">
                                    选择规格：统一规格
                                </div>
                            </div>
                        </div>
                    </div>
                    <div v-show="productPopupData?.description" style="padding: 0 10px">
                        <div class="product_describe">
                            <span class="describe">产品描述</span>
                            <div class="describe_text" v-html="productPopupData?.description"></div>
                        </div>
                    </div>
                    <div v-show="productPopupData?.graphic_details" style="padding: 0 10px">
                        <div class="product_describe">
                            <span class="describe">图文详情</span>
                            <div v-if="[10].includes(productPopupData.source)" class="describe_text">
                                <p>
                                    <img
                                        v-for="img in productPopupData.graphic_details"
                                        :key="img"
                                        :src="img"
                                        alt=""
                                        class="describe_img" />
                                </p>
                            </div>
                            <div v-else class="describe_text" v-html="productPopupData?.graphic_details"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </el-drawer>
</template>
<script setup lang="ts">
import { ref, reactive } from 'vue';
defineProps(['productPopupData']);
const drawer = ref(false);

defineExpose({ drawer });
</script>
<style lang="scss" scoped>
.slot {
    border-bottom: 1px solid #eaeaea;
    margin: -32px -16px 0;
}
.product_box {
    .mobile_box {
        box-sizing: content-box;
        width: 414px;
        padding: 16px;
        border-radius: 25px;
        border: 1px solid #d2d8db;
        background-color: #f3fafb;
        margin: 0 auto;
        margin-top: 40px;
        .white_box {
            width: 100%;
            background-color: #fff;
            // height: 840px;
        }
        .title_box {
            display: flex;
            align-items: center;
            height: 44px;
            padding-left: 11px;
            background: #29a9f5;
            border-radius: 15px 15px 0px 0px;
            color: #fff;
            .title_r {
                flex: 1;
                text-align: center;
            }
        }
        .product_pic {
            display: flex;
            justify-content: center;
        }
        .product_information {
            margin-top: 16px;
            min-height: 65px;
            background: #ffffff;
            box-shadow: 0px 6px 10px 0px rgba(46, 91, 255, 0.07);
            border-radius: 8px;
            border: 1px solid #eff2ff;
            padding: 16px 12px 0;
            color: #282828;
            font-weight: 550;
            font-size: 18px;
            .Price {
                display: flex;
                justify-content: space-between;
                align-items: center;
                color: #969696;
                font-size: 14px;
                margin-top: 16px;
            }
            .specs_box {
                display: flex;
                flex-wrap: wrap;
                margin-top: 20px;
                .specs_rule {
                    font-size: 14px;
                    color: #969696;
                    line-height: 29px;
                }
                .specs_text {
                    min-width: 85px;
                    // height: 26px;
                    background: #f7f7f7;
                    border-radius: 6px;
                    border: 1px solid #e3e3e3;
                    font-size: 14px;
                    color: #969696;
                    margin: 0 12px 12px 0;
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    padding: 5px;
                    word-break: break-all;
                    line-height: 18px;
                }
                .active {
                    background: #eff2ff;
                    color: #0081ff;
                }
            }
        }
        .product_describe {
            margin-top: 16px;
            min-height: 100px;
            background: #ffffff;
            box-shadow: 0px 6px 10px 0px rgba(46, 91, 255, 0.07);
            border-radius: 8px;
            border: 1px solid #eff2ff;
            padding: 16px 12px 0;
            .describe {
                color: #282828;
                font-weight: 550;
                font-size: 18px;
            }
            .describe_text {
                margin-top: 13px;
                line-height: 20px;
                color: #969696;
                font-size: 14px;
                overflow: hidden;
                .describe_img {
                    max-width: 100%;
                }
            }
        }
    }
}
.scroll {
    height: 900px;
    overflow-y: scroll;
}
</style>
